
import java.io.*;
import java.util.ArrayList;

public class Topic implements Serializable {
    private static int id_counter = 1;
    private int id;
    private String name;
    private ArrayList<Idea> ideas = new ArrayList<>();

    public Topic() {
        this.id = id_counter;
        id_counter++;
        this.name = "Default Topic";
    }

    public Topic(String n, String d) {
        this.id = id_counter;
        id_counter++;
        this.name = n;
    }

    public int getId(){
        return this.id;
    }

    public String getName(){
        return this.name;
    }

    public ArrayList<Idea> getIdeas(){
        return this.ideas;
    }

    public void setName(String n){
        this.name = n;
    }

    public void addIdea(Idea i){
        this.ideas.add(i);
    }

    public void removeIdea(Idea i){
        this.ideas.remove(i);
    }

    public void listIdeas(){
        for(int i=0; i<this.ideas.size(); i++){
            System.out.println(" (" + i + ") " + this.ideas.get(i).getName());
        }
    }

    @Override
    public String toString() {
        String i = String.valueOf(this.id);
        return "ID= " + i + ",Topic= " + this.name;
    }
}
